package cn.edu.njpi.two;

import java.util.Random;

/**
 * @author 朱宗辉
 * @version V1.0
 * @Package cn.edu.njpi.two
 * @date 2021/7/11 22:51
 */
public class Request {
    private final String name;  // 委托者
    private final int number;   // 请求者的编号
    private static final Random random = new Random();

    public Request(String name, int number) {
        this.name = name;
        this.number = number;
    }

    public void execute() {
        System.out.println(Thread.currentThread().getName() + " execute " + this);
        try {
            Thread.sleep(random.nextInt(1000));
        } catch (Exception e) {
        }
    }

    @Override
    public String toString() {
        return "[ Request from " + name + " No." + number + " ]";
    }
}
